<template>
    <rx-layout style="padding: 10px">
        <template #middle>
            <rx-fit v-model="fitSearch">
                <template #head>
                    <div style="display: flex;align-items: center;justify-content: space-between;">
                        <div class="table-operator"></div>
                        <span class="search-btn" @click.stop="searchshow" @mousedown.stop><SearchOutlined/>{{
                                $ti18('rxList.leachBtn', '过滤')
                            }}</span>
                    </div>
                </template>
                <template #search>
                    <a-form layout="vertical">
                        <a-form-item :label="i18n('form.listName','列表名称')">
                            <a-input :placeholder="i18n('form.listName','请输入列表名称','input')" v-model:value="urlConfig.queryParam.Q_LIST_NAME__S_LK"/>
                        </a-form-item>
                        <a-form-item :label="i18n('form.subject','记录标题')">
                            <a-input :placeholder="i18n('form.listName','请输入记录标题','input')" v-model:value="urlConfig.queryParam.Q_SUBJECT__S_LK"/>
                        </a-form-item>
                        <a-form-item :label="i18n('form.subject','导入状态')">
                            <a-select v-model:value="urlConfig.queryParam.Q_STATUS__S_LK">
                                <a-select-option value="0">{{i18n('statusMap.fail','失败')}}</a-select-option>
                                <a-select-option value="1">{{i18n('statusMap.success','成功')}}</a-select-option>
                                <a-select-option value="2">{{i18n('statusMap.importing','正在导入')}}</a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-form>
                    <div class="list-search-toolbar">
                        <a-button type="primary" @click="search">
                            <SearchOutlined/>
                            {{ $ti18('rxList.searchBtn', '查询') }}
                        </a-button>
                        <a-button style="margin-left: 4px" @click="resetSearch">
                            <RedoOutlined/>
                            {{ $ti18('rxList.resetBtn', '重置') }}
                        </a-button>
                    </div>
                </template>
                <template #middle>
                    <rx-grid ref="table"
                             :hasPage="true"
                             :urlConfig="urlConfig"
                             :selectConfig="selectConfig"
                             url="/api-form/form/core/formImportRecord/query"
                             field="id"
                             :columns="columns"
                    >
                        <template #status="{row}">
                            <a-tag :color="statusMap[row.status].color">
                                <span>{{ statusMap[row.status].text }}</span>
                            </a-tag>
                        </template>
                        <template #action="{ row }">
                            <RxGridAction :size="2">
                                <div @click.stop="detail(row)">{{i18n("list.detail",'详情')}}</div>
                            </RxGridAction>
                        </template>
                    </rx-grid>
                </template>
            </rx-fit>
        </template>
    </rx-layout>
</template>

<script>
import FormImportRecordApi from '@/common/api/form/formImportRecord'
import FormImportRecordEdit from './FormImportRecordEdit.vue'
import {BaseList, RxFit, RxGrid} from '@lowcode/jpaas-base-lib';

export default {
    name: 'FormImportRecordList',
    mixins: [BaseList],
    components: {
        RxFit
    },
    data() {
        return {
            urlConfig: {
                ajaxType: 'post',
                contentType: 'json',
                queryParam: {},
                dataField: 'result.data',
                totalField: 'result.totalCount'
            },
            selectConfig: {
                type: 'checkbox',
            },
            columns: [
                {title: this.i18n('form.listName','列表名称'), field: 'listName', minWidth: 100},
                {title: this.i18n('form.status','导入状态'), field: 'status', minWidth: 50, slots: {default: 'status'}},
                {title: this.i18n('form.subject','记录标题'), field: 'subject', minWidth: 250},
                {title: this.i18n('form.createByName','创建人名称'), field: 'createByName', minWidth: 50},
                {title: this.i18n('form.createTime','创建时间'), field: 'createTime', minWidth: 100},
                {title: this.$ti18('rxList.action','操作'), minWidth: 50, field: 'action', slots: {default: 'action'}}
            ],
            component: FormImportRecordEdit,
            widthHeight:['800px','500px'],
            comment: this.i18n('list.comment','Excel导入记录(异步)'),
            statusMap: {
                1: {color: 'green', text: this.i18n('statusMap.success','成功')},
                0: {color: 'red', text: this.i18n('statusMap.fail','失败')},
                2: {color: 'orange', text: this.i18n('statusMap.importing','正在导入')}
            },
        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"FormImportRecord",key);
        },
        delById(ids) {
            return FormImportRecordApi.del({ids: ids.join(',')});
        },
    }
}
</script>
<style scoped>
.table-operator {
    padding: 4px;
}

.table-operator button {
    margin: 2px;
}
</style>

